package org.yn.subject.common.util;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 分页响应
 *
 * @author Bing
 * @version 1.0
 **/
@Setter
@Getter
@Accessors(chain = true)
public class PageReq {

  /**
   * 是否分页
   */
  private boolean pageable;
  /**
   * 当前页码
   *
   * @mock 0
   */
  private int pageIndex;

  /**
   * 分页大小
   *
   * @mock 10
   */
  private int pageSize;

  public static PageReq unPage() {
    return new PageReq().setPageable(false);
  }

  public static PageReq of(int pageIndex, int pageSize) {
    return new PageReq().setPageable(true).setPageIndex(pageIndex).setPageSize(pageSize);
  }

  @Getter
  @AllArgsConstructor
  public static class Filter {

    /**
     * 过滤键名
     */
    private String key;
    /**
     * 值
     */
    private Object value;
  }

  @Getter
  @AllArgsConstructor
  public static class Sort {

    /**
     * 排序键名
     */
    private String key;
    /**
     * 排序方式,asc升序,desc降序
     */
    private String value;
  }
}
